package tn.orange.canreminder;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.KeyEvent;

public class HomeActivity extends Activity {
	/** Called when the activity is first created. */
	public boolean isBackPressed = false;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.home);
	}

	@Override
	protected void onResume() {
		super.onResume();
		new Handler().postDelayed(new Runnable() {
			@Override
			public void run() {
				if (!isBackPressed) {

					final Intent mainIntent = new Intent(HomeActivity.this,
							DashboardActivity.class);
					startActivity(mainIntent);
					finish();
				}
			}
		}, 3000);
	}

	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		if (keyCode == KeyEvent.KEYCODE_BACK) {
			finish();
			isBackPressed = true;

			return true;
		}
		return super.onKeyDown(keyCode, event);
	}

}